<template>
    <view class="page">
        <div class="bg">
            <Nimg src="008.png" width="750" height="894" />
        </div>
        <div class="main">
            <div class="header fx jcc" :style="'padding-top:' + header_p_top">
                个人中心
            </div>
            <div class="user">
                <div class="fx p_1" @click="$go('zhanghaoshezhi')">
                    <div class="face boxShadow" v-if="us.headimgurl">
                        <Nimg
                            :src="us.headimgurl"
                            mode="aspectFill"
                            width="120"
                            height="120"
                        />
                    </div>
                    <div class="face" v-else>
                        <Nimg src="006s.png" width="120" height="120" />
                    </div>
                    <div class="ustxt">
                        <div class="name" v-if="us.nickname">
                            {{ us.nickname }}
                        </div>
                        <div class="name" v-else>微信用户</div>
                        <div class="phone fx DN">
                            <div class="icon">
                                <Nimg src="009.png" width="29" height="33" />
                            </div>
                            <div class="wb">
                                {{ phone || "暂未设置手机号" }}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="menu boxShadow">
                <div class="line fx" @click="$go('dingdan')">
                    <div class="icon fx jcc">
                        <Nimg src="012.png" width="60" height="60" />
                    </div>
                    <div class="wb">我的订单</div>
                    <div class="fx1"></div>
                    <Nimg src="013.png" width="32" height="32" />
                </div>
                <div class="line fx" @click="$go('fankui')">
                    <div class="icon fx jcc">
                        <Nimg src="011.png" width="60" height="60" />
                    </div>
                    <div class="wb">意见反馈</div>
                    <div class="fx1"></div>
                    <Nimg src="013.png" width="32" height="32" />
                </div>
                <div class="line fx" @click="lianxikefu">
                    <div class="icon fx jcc">
                        <Nimg src="010.png" width="35" height="36" />
                    </div>
                    <div class="wb">联系客服</div>
                    <div class="fx1"></div>
                    <Nimg src="013.png" width="32" height="32" />
                </div>
            </div>
        </div>
        <custom-tab-bar active="gerenzhongxin"></custom-tab-bar>
    </view>
</template>

<script>
import $ from "@/common";
export default {
    data() {
        return {
            header_p_top: "",
            phone: "",
            us: {},
            service_tel: "",
        };
    },
    methods: {
        setHeader() {
            const res = wx.getMenuButtonBoundingClientRect();
            this.header_p_top = res.top + "px";
        },
        lianxikefu() {
            $.call(this.service_tel);
        },
        getKefu() {
            let url = $.index("tel");
            $.post(url).then((res) => {
                if (res.isError) {
                    return;
                }
                this.service_tel = res.tel;
            });
        },
    },
    onShow() {
        this.setHeader();

        $.login(() => {
            this.getKefu();
            $.getUsInfo().then((us) => {
                if (us.headimgurl !== "") {
                    if (!us.headimgurl.startsWith("http")) {
                        us.headimgurl = "/upload/user/" + us.headimgurl;
                    }
                }

                this.us = us;
            });
        });
    },
};
</script>

<style lang="less" scoped>
.page {
    width: 100vw;
    height: 100vh;
    background: #f8f8f8;
    position: relative;
    .main {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 2;
        .header {
            color: #000000;
            font-size: 35rpx;
            font-weight: bold;
            height: 150rpx;
        }
        .p_1 {
            padding-left: 60rpx;
            padding-top: 50rpx;
            .face {
                width: 120rpx;
                height: 120rpx;
                border-radius: 50%;
                overflow: hidden;
            }
            .ustxt {
                padding-left: 24rpx;
                .name {
                    color: #000000;
                    font-size: 32rpx;
                    font-weight: bold;
                    margin-right: 5;
                }
                .phone {
                    padding-top: 26rpx;
                }
                .wb {
                    color: #575757;
                    margin-left: 10rpx;
                }
            }
        }

        .menu {
            width: 696rpx;
            margin: 0 auto;
            border-radius: 30rpx;
            overflow: hidden;
            margin-top: 40rpx;
            .line {
                height: 96rpx;
                background: #fff;
                padding: 0 20rpx;
                padding-right: 30rpx;
                font-size: 28rpx;
                .icon {
                    width: 90rpx;
                    height: 90rpx;
                }
            }
        }
    }
}
</style>

